First-class polymorphism with existential types
نویسنده
چکیده
Abstract datatypes can be typed conveniently using existential types. Even though it is a powerful abstraction mechanism, current type inference systems based on Hindley-Milner do not allow existential types as first-class citizens – every existential type must be explicitly declared, packed, and unpacked using a data constructor. We present an extension of theMLF type system with first-class existential types. Existential types are simply introduced by an annotation, and eliminated automatically in applications without the need for a special open construct. The system is fully implemented in the experimental Morrow interpreter.datatypes can be typed conveniently using existential types. Even though it is a powerful abstraction mechanism, current type inference systems based on Hindley-Milner do not allow existential types as first-class citizens – every existential type must be explicitly declared, packed, and unpacked using a data constructor. We present an extension of theMLF type system with first-class existential types. Existential types are simply introduced by an annotation, and eliminated automatically in applications without the need for a special open construct. The system is fully implemented in the experimental Morrow interpreter.
منابع مشابه
Type Classes with Existential Types
We argue that the novel combination of type classes and existential types in a single language yields significant expressive power. We explore this combination in the context of higher-order functional languages with static typing, parametric polymorphism, algebraic data types, and Hindley-Milner type inference. Adding existential types to an existing functional language that already features t...
متن کاملHigher-order modules in System Fω and Haskell
To argue that it is practical to extend core Haskell to support higher-order modules, we translate Dreyer, Crary, and Harper’s higher-order module system (2002, 2003) into System Fω. Our translation is the first to fully treat generative functors (with existential types) alongside applicative ones (with Skolemized types). Applicative functors correspond to higher-order polymorphism in idiomatic...
متن کاملCombining Type Classes and Existential Types
This paper demonstrates that the novel combination of type classes and existential types adds significant expressive power to a language, requiring only a minor syntactic change. We explore this combination in the context of higher-order functional languages with static typing, parametric polymorphism, algebraic data types, and Hindley-Milner type inference. Since we have examined the underlyin...
متن کاملA Recipe for Raw Types
The design of GJ (Bracha, Odersky, Stoutamire and Wadler), an extension of Java with parametric polymorphism, was significantly affected by the issue of compatibility between legacy Java code and new GJ code. In particular, the introduction of raw types made it easier to interface polymorphic code with monomorphic code. In GJ, for example, a polymorphic class List, parameterized by the eleme...
متن کاملA Framework for Extended Algebraic Data Types
Data Types have Existential Types data Stack a = forall s. Stack s -self (a->s->s) -push (s->s) -pop (s->a) -top (s->Bool) -empty push :: a -> Stack a -> Stack a push x (Stack s push’ pop top empty) = Stack (push’ x s) push’ pop top empty pop :: Stack a -> Stack a pop (Stack s push pop’ top empty) = Stack (pop’ s) push pop’ top empty A Framework for Extended Algebraic Data Types – p.6 Abstract ...
متن کامل